package com.itcast.springboot.waste_recovery.controller;


import com.itcast.springboot.waste_recovery.common.CommonResult;
import com.itcast.springboot.waste_recovery.common.CommonResultCode;
import com.itcast.springboot.waste_recovery.domain.WasteClassification;
import com.itcast.springboot.waste_recovery.service.WasteClassificationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 * 垃圾分类表 前端控制器
 * </p>
 *
 * @author 小破烂
 * @since 2020-08-19
 */
@RestController
@RequestMapping("/waste_recovery/waste-classification")
@Slf4j
@Api(tags = "垃圾分类类接口")
public class WasteClassificationController {
    @Resource
    WasteClassificationService wasteClassificationService;

    @GetMapping("/customer/all")
    @ApiOperation(value = "废品分类")
    @RequiresPermissions(value = {"user-operated", "staff-operated"}, logical = Logical.OR)       //拥有 user-operated或者staff-operated 才可以访问
    public CommonResult getWasteClassifications(){
        Map<String, Object> map = wasteClassificationService.getWasteClassifications();
        return new CommonResult<Map>(CommonResultCode.CommonSuccess, map);
    }
}

